<?php
//引入类文件自动加载
require_once __DIR__ . '/../../autoload.php';
//引入用户信息检查类
use  src\DataBase;
//接受post参数
$roomID=trim($_POST['roomID']);
$studentInfo=$_COOKIE['school']['username'];
$coursesName=trim($_POST['courses']);
$coursetime=trim($_POST['coursetime']);
//new一个选课记录插入数据库操作对象,并传入参数
$db= new DataBase\DataBaseOperate('139.196.124.180','school','user1','Mcx857264','utf8');
$insertResult = $db->insert('courseSelectionRecord',array('roomID'=>$roomID,'studentInfo'=>$studentInfo,'courseName'=>$coursesName,'courseTime'=>$coursetime,'insertTime'=>time()));
//结果判断,并返回
if($insertResult == true){
	exit(json_encode(array('code'=>1,'msg'=>'选课成功')));
}else{
	exit(json_encode(array('code'=>0,'msg'=>'选课失败')));
}
